<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>销售单模块</title>

    <!--data table-->
    <link rel="stylesheet" href="js/data-tables/DT_bootstrap.css" />

    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

    <style type="text/css">
        #all_light { /*整个弹窗的页面*/
            opacity: 0.8; /*透明度*/
            width: 100%; /*宽度*/
            height: 2300px; /*高度，不能百分百*/
            background: #000; /*背景色*/
            position: absolute;
            top: 0;
            left: 0; /*定位*/
            display: none; /*隐藏*/
            z-index: 2; /*覆盖*/
        }
        #contes { /* 弹框的页面*/
            width: 500px; /*宽度*/
            height: 500px; /*高度*/
            background: #fff; /*背景色*/
            display: none; /*隐藏*/
            z-index: 2; /*覆盖*/
            position: absolute;
            top: 100px;
            left: 400px; /* 定位*/
        }
        input{
            margin-bottom: 10px;
        }
    </style>

</head>

<body class="sticky-header">


<section>
    <!-- left side start-->
    <script src="left.js"></script>
    <!-- left side end-->

    <!-- main content start-->
    <div class="main-content" >

        <!-- header section start-->
        <div class="header-section">

            <!--toggle button start-->
            <a class="toggle-btn"><i class="fa fa-bars"></i></a>
            <!--toggle button end-->


        </div>
        <!-- header section end-->

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                销售单模块
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">首页</a>
                </li>
                <li>
                    <a href="#">系统信息</a>
                </li>
                <li class="active"> 销售单模块 </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <section class="panel">
                        <header class="panel-heading">
                            销售单信息
                            <br><label><input type="text"  id="queryMsg" placeholder="订单号查找" />
                            <button onclick="findBySearch()">搜索</button>
                        </label>

                            <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>
                        <a href="javascript:;" class="fa fa-times"></a>
                     </span>
                        </header>
                        <div class="panel-body">
                            <div class="adv-table editable-table ">
                                <div class="clearfix">
                                    <div class="btn-group pull-right">
                                        <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Tools <i class="fa fa-angle-down"></i>
                                        </button>
                                        <ul class="dropdown-menu pull-right">
                                            <li><a href="#">Print</a></li>
                                            <li><a href="#">Save as PDF</a></li>
                                            <li><a href="#">Export to Excel</a></li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="space15"></div>
                                <!-- 表格 -->
                                <table class="table table-striped table-hover table-bordered"
                                       id="editable-sample">
                                    <thead>
                                    <tr>
                                        <th prop="id">订单号</th>
                                        <th prop="name">货品分类名称</th>
                                        <th prop="sum">出库数量</th>
                                        <th prop="attr">货品属性</th>
                                        <th prop="perPrice">货品单价</th>
                                        <th prop="sumPrice">货品总价</th>
                                        <th prop="wid">所属仓库</th>
                                        <th prop="isPass">管理员是否批准</th>
                                        <th prop="supplierName">客户</th>
                                        <th prop="dept">处理部门</th>
                                        <th prop="updateTime">操作时间</th>
                                        <th>导出信息</th>
                                    </tr>
                                    </thead>

                                    <tbody id="newList">

                                    </tbody>
                                </table>
                            </div>

                        </div>
                        <div col-lg-6>

                            <div class="dataTables_paginate paging_bootstrap pagination">

                                <ul id="pagination">

                                </ul>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->



    </div>
    <!-- main content end-->
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="js/jquery-migrate-1.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/modernizr.min.js"></script>
<script src="js/jquery.nicescroll.js"></script>

<!--data table-->
<script type="text/javascript" src="js/data-tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/data-tables/DT_bootstrap.js"></script>

<!--common scripts for all pages-->
<script src="js/scripts.js"></script>

<!--script for editable table-->
<script src="js/editable-table.js"></script>

<!-- END JAVASCRIPTS -->
<script src="orders.js"></script>
<script>
    window.onload=function (){
        var order;
        $.ajax({
            url:"/users/getOrder",
            type:"get",
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                order=res;
                if(order==2){
                    order2();
                }
                if(order==3){
                    order3();
                }
            },
            error:function (){

            }
        })

        load();
    }
    var pagination={ //分页信息
        currentPage:1,
        pageSize:5,
        totalPage:10
    }

    //导出信息
    function daochu(id){
        $.ajax({
            url:"/chuku/daochuById/"+id,
            type:"GET",
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                alert(res.msg)
            },
            error:function (){
            }
        })
    }

    //搜索框搜索
    function findBySearch() {
        var query=$("#queryMsg").val()
        gopage(1,query)
    }

    //序列化Json
    function getFormJson(form) {
        var o = {};
        var a = form
        $.each(a, function () {
            if (o[this.name] !== undefined) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    }

    //展示入库信息列表
    function showList(list,sum,index,query){
        $('#newList').empty();
        for(var i=0;i<list.length;i++) {
            var tr="<tr>\n" +
                "<td>"+list[i].id+"</td>\n" +
                "<td>"+list[i].good.name+"</td>\n" +
                "<td>"+list[i].sum+"</td>\n" +
                "<td >"+list[i].status.attr+"</td>\n" +
                "<td>"+list[i].good.perPrice+"</td>\n" +
                "<td>"+list[i].totalPrice+"</td>\n" +
                "<td>"+list[i].wid+"</td>\n" +
                "<td >"+list[i].pass+"</td>\n" +
                "<td>"+list[i].customer.name+"</td>\n" +
                "<td>"+list[i].dept.name+"</td>\n" +
                "<td>"+list[i].updateTime+"</td>\n" +
                "<td><button style='background-color: #55d455 ' onclick=\"daochu("+list[i].id+")\">导出销售单信息</button></td>\n" +
                "</tr>"
            console.log(tr)
            $("#newList").append(tr);
        }
        $('#pagination').empty();
        for(var i=1;i<=sum;i++){
            if(i==index)var li="<li><button style='color: red' onclick=\"gopage("+i+","+query+")\">"+i+"</button></li>";
            else var li="<li><button onclick=\"gopage("+i+","+query+")\">"+i+"</button></li>";
            $("#pagination").append(li);
        }
    }

    //去xx页面
    function gopage(i,query){
        // $('#newList').empty();
        pagination.currentPage=i;//修改当前页码
        if(query==0){
            query=''
        }
        $.ajax({
            url:"/chuku/getList",
            type:"POST",
            data:'{"currentPage":"'+pagination.currentPage+'","pageSize":"'+pagination.pageSize+'","queryMsg":"'+query+'"}',
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                if (res.success){
                    var l=res.data.list//重新赋值
                    var sum=res.data.totalPage;//更新总页数
                    showList(l,sum,i,query)
                }
                else{
                    alert("查询失败!")
                }
            },
            error:function (){

            }
        })


    }
    function load(){
        gopage(1,null);
    }




</script>


</body>
</html>
